package collection.map;


import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * 遍历map集合的第二种方式，entrySet
 */
public class Demo02MapPractice {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("007", "hello");
        map.put("002", "hello2");
        map.put("003", "hello3");
        map.put("004", "hello4");
        map.put("005", "hello5");

        Set<Map.Entry<String, String>> entries = map.entrySet();
        Iterator<Map.Entry<String, String>> iterator = entries.iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            System.out.println(next.getKey() + "=" + next.getValue());
        }
    }
}
